<!-- workSplace -->
<template>
  <div>
    <div class="workLeft">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="最新职位" name="newest"></el-tab-pane>
        <el-tab-pane label="热门职位" name="hotest"></el-tab-pane>
      </el-tabs>
      <div class="workContain">
        <div
          class="workCard"
          v-for="(item, index) in workArray"
          :key="index"
          divided
          @click="goDetails(item.id)"
        >
          <div class="workImg">
            <img src="@/assets/img/logo.svg" alt="workImg" />
          </div>
          <div class="work_details" divided>
            <div>{{ item.title }}</div>
            <div>{{ item.publisher.username }}</div>
            <div>{{ item.province }} {{ item.city }}</div>
            <div>{{ item.tags_string }}</div>
          </div>
        </div>
      </div>
      <div></div>
    </div>
  </div>
</template>

<script>
import { jobsInit } from "@/api/workSpalce";
export default {
  name: "workSplace",
  data() {
    return {
      activeName: "newest",
      hide: true,
      workArray: [],
    };
  },
  computed: {},
  mounted() {
    jobsInit(0, 10)
      .then((response) => {
        this.workArray = response.data._embedded.jobs;
        console.log(
          response.data.page.total_elements,
          response.data._embedded.jobs
        );
      })
      .catch((error) => {
        reject(error);
      });
  },
  methods: {
    goDetails(id) {
      this.$router.push("/work" + "?workId=" + id);
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
  },
};
</script>

<style lang='scss' scoped>
@import "@/assets/css/workSplace.scss";
</style>